part of common_lib_plugin;

extension IterableExtension on Iterable? {
  bool get isNotNull {
    return this != null && this!.isNotEmpty;
  }

  bool get isNil {
    return this == null || this!.isEmpty;
  }
}

extension InlineAdd<T> on Iterable<T> {
  Iterable<T> operator +(T other) => followedBy([other]);

  Iterable<T> operator &(Iterable<T> other) => followedBy(other);
}

extension CompactMap<T> on Iterable<T?> {
  Iterable<T> compactMap<E>([
    E? Function(T?)? transform,
  ]) =>
      map(transform ?? (e) => e).where((e) => e != null).cast();
}

// void main() {
  // const list = ['Hello', null, 'World'];
  // print(list); // [Hello, null, World]
  // print(list.compactMap()); // [Hello, World]
  // print(list.compactMap((e) => e?.toUpperCase())); // [HELLO, WORLD]
// }
